Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(autoware_path_generator): function to smooth the path #227

Open
wants to merge 51 commits into
base: main
Choose a base branch
from

Conversation

sasakisasaki
Copy link
Contributor

@sasakisasaki sasakisasaki commented Feb 26, 2025

Description

This is kind of feature porting from autoware.universe as follows

  • Import PathWithLaneId DefaultFixedGoalPlanner::modifyPathForSmoothGoalConnection from the autoware.universe side code
  • Also import all related functions from the autoware.universe side

Quality of Code

  • NOT ENOUGH YET. I'm improving the code quality so this PR is ready for review.
  • The unit tests for the added feature has not been added yet.

The refactoring plan is mentioned in this issue.
Perhaps we can work on the refactoring with a few PRs. Including this idea for refactoring, please feel free to share your idea for the improvement of code quality. Thank you!

How was this PR tested?

  • I did vcs import at around 18:00 JST on 26th Feb. 2025
  • The executed commands are as follows:
$ git clone https://github.com/autowarefoundation/autoware.git
$ cd autoware

# Before the build
$ ./setup-dev-env.sh -y

(Enter password for user)

(ADDED: Perhaps you need to do `sudo shutdown -r now` for applying NVIDIA driver update)

$ vcs import src < autoware.repos

$ vim autoware-nightly.repos

(Edited `autoware.core` part so it used my branch on forked)

$ vcs import src < autoware-nightly.repos
$ source ~/autoware/install/setup.bash
$ sudo apt update && sudo apt upgrade
$ rosdep update
$ rosdep install -y --from-paths src --ignore-src --rosdistro $ROS_DISTRO

# Deploy the attached three files for the following place, respectively
# - src/launcher/autoware_launch/autoware_launch/config/planning/scenario_planning/lane_driving/behavior_planning/path_generator.param.yaml
# - src/launcher/autoware_launch/autoware_launch/launch/components/tier4_planning_component.launch.xml
# - src/universe/autoware.universe/launch/tier4_planning_launch/launch/scenario_planning/lane_driving/behavior_planning/behavior_planning.launch.xml

behavior_planning_launch_xml.txt
tier4_planning_component_launch_xml.txt
path_generator_param_yaml.txt

# Now start colcon build
$ colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release

# Checked by psim
$ ros2 launch autoware_launch planning_simulator.launch.xml map_path:=$HOME/autoware_map/sample-map-planning vehicle_model:=sample_vehicle sensor_model:=sample_sensor_kit
Screencast_psim.webm

Status of Additional Tests

(ADDED) It seems the tests on the evaluator shows a failed scenario link to failed one. I'm now investigating the issue.

Notes for reviewers

Please do not enable auto merge as this PR needed to be merged with this launch side PR at the same time.
Please feel free to provide all the needed tests for merging this PR. I'm really happy for performing the tests 👍

Effects on system behavior

Needed to be investigated during the testing process.

  Description:
    This commit is kind of feature porting from `autoware.universe` as follows
      * Import `PathWithLaneId DefaultFixedGoalPlanner::modifyPathForSmoothGoalConnection` from the following `autoware.universe` code
          https://github.com/autowarefoundation/autoware.universe/blob/a0816b7e3e35fbe822fefbb9c9a8132365608b49/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/default_fixed_goal_planner.cpp#L74-L104
      * Also import all related functions from the `autoware.universe` side

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Copy link

github-actions bot commented Feb 26, 2025

Thank you for contributing to the Autoware project!

🚧 If your pull request is in progress, switch it to draft mode.

Please ensure:

@sasakisasaki sasakisasaki added run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) component:planning Route planning, decision-making, and navigation. (auto-assigned) labels Feb 26, 2025
@sasakisasaki sasakisasaki self-assigned this Feb 26, 2025
@xmfcx xmfcx added the type:new-feature New functionalities or additions, feature requests. label Feb 28, 2025
Copy link

codecov bot commented Feb 28, 2025

Codecov Report

Attention: Patch coverage is 63.02521% with 44 lines in your changes missing coverage. Please review.

Project coverage is 8.26%. Comparing base (4cb18f5) to head (d9b3a8d).
Report is 69 commits behind head on main.

Files with missing lines Patch % Lines
planning/autoware_path_generator/src/utils.cpp 61.22% 21 Missing and 17 partials ⚠️
planning/autoware_path_generator/src/node.cpp 71.42% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #227       +/-   ##
==========================================
- Coverage   78.75%   8.26%   -70.49%     
==========================================
  Files          11     122      +111     
  Lines         193   10196    +10003     
  Branches       73    1255     +1182     
==========================================
+ Hits          152     843      +691     
- Misses         11    9219     +9208     
- Partials       30     134      +104     
Flag Coverage Δ
differential 8.26% <63.02%> (?)
total ?

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Comment on lines 53 to 54
const double seg_dist =
autoware::motion_utils::calcSignedArcLength(input.points, seg_idx, seg_idx + 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just calc_distance2d ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this informative comment. I also guessed this is just a calculation for 2-dimensional distance between two points. If this is not my misunderstanding, the calcSignedArcLength() function calculates the total path length by summing up the 2D distances between consecutive points, as shown in the following code:

Ref. to code:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we need to ensure which method should we use.

* @param goal_lanelet Goal lanelet.
* @return True if the goal lanelet is found, false otherwise
*/
bool get_goal_lanelet(const PlannerData & planner_data, lanelet::ConstLanelet * goal_lanelet);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better not to use raw pointer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by this commit 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm not fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, sorry for my bad! Let me fix soon!

sasakisasaki and others added 7 commits February 28, 2025 18:11
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>

Co-authored-by: Kosuke Takeuchi <kosuke.tnp@gmail.com>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>

Co-authored-by: Kosuke Takeuchi <kosuke.tnp@gmail.com>
  * Enhance error handlings
  * Remove unused variables
  * Simplify the code
  * Improve readability a little bit

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
…sasakisasaki/autoware.core into feat-embed-smooth-path-as-alpha-quality

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
sasakisasaki added a commit to sasakisasaki/autoware_launch that referenced this pull request Mar 4, 2025
  * This fix is for the following PR:
      autowarefoundation/autoware.core#227

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
  * This comment is wrote because of my misunderstanding

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
@sasakisasaki
Copy link
Contributor Author

Fixing error in some CI checks.

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
sasakisasaki and others added 7 commits March 5, 2025 19:54
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
  * The goal position is generally separate from the path points

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
  * CI (especially unit tests) fails due to this sanity check
  * As this is out of scope for this PR, we will fix the bug
    where the start and end are reversed in another PR

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
  * We should start from the simple one
  * Then we can add the necessary optimization later

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
@@ -12,3 +12,5 @@
search_distance: 30.0
resampling_interval: 1.0
angle_threshold_deg: 15.0
refine_goal_search_radius_range: 10.0 # [m]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default value in behavior_path_planner is

refine_goal_search_radius_range: 7.5

do you have any reason chagagin from that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback! Let me fix this to 7.5, as there is no specific reason. The reason was experimental use on the testing phase.

Comment on lines 364 to 365
// Replace the goal point with the refined goal
filtered_path.points.back().point.pose = goal;
Copy link
Contributor

@kosuke55 kosuke55 Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️

Is only the goal being replaced now?
Are the other points in the refine_goal_search_radius_range range be retained?
If so, I wonder if the goal and one of its previous points will have a larger deviation, causing a distortion of the path.

The original algorithm generates a smooth path by smoothly connecting between refine_goal_search_radius_range. After the points deletion, spline interpolation is executed in a later stage of the process to smooth them out.
please check original logic.
https://autowarefoundation.github.io/autoware.universe/main/planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/#fixed_goal_planner

Copy link
Contributor

@kosuke55 kosuke55 Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I dit not give enough infomartion. 🙇

After the deletion, the splines are executed in a later stage of the process to smooth them out.

seems here: https://github.com/tier4/autoware.universe/blob/908cb7ee5cca01c367f03caf6db4562a620504fb/planning/behavior_path_planner/autoware_behavior_path_planner/src/behavior_path_planner_node.cpp#L724-L725

so behavior path logic is

  • set refined goal and remove points whitiin radius in fixed_goal_planner side
  • spline interpolation is in behaivor_path_planner side

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

( this comment is by just reading code. I have not checked actual behavior in psim. I'm building now... )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the detailed and kind lecture! It seems my misunderstanding is derived from as follows. Now I should be understanding the point. Let me fix this too!

  • The minimum distance range is assumed not from the current position (front of the path points), but from the goal

@kosuke55 kosuke55 changed the title feat(autoware_path_generator): function to smooth the route feat(autoware_path_generator): function to smooth the path Mar 8, 2025
@kosuke55
Copy link
Contributor

kosuke55 commented Mar 8, 2025

I changed PR title route -> path. route is like missoin level output

@kosuke55
Copy link
Contributor

kosuke55 commented Mar 8, 2025

reopened #227 (comment)

Comment on lines +406 to +407

if (distance_to_goal < planner_data_.path_generator_parameters.refine_goal_search_radius_range) {
Copy link
Contributor

@kosuke55 kosuke55 Mar 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now this is a limitation:
cannnot generate paths to goals further than refine_goal_search_radius_range from the centerline.
I want to resolve this limitation in a later PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh, that is good observation. I did not notice such the wider road case.
In this PR, let us keep this specification the that limitation. Maybe we can use the width of the whole road to optimize the search radius range automatically.

@kosuke55 kosuke55 self-assigned this Mar 8, 2025
sasakisasaki and others added 14 commits March 8, 2025 20:28
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
  * The type of returned value and arguments were wrong

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
…or/common_structs.hpp


Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>

Co-authored-by: Kosuke Takeuchi <kosuke.tnp@gmail.com>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>

Co-authored-by: Kosuke Takeuchi <kosuke.tnp@gmail.com>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>

Co-authored-by: Kosuke Takeuchi <kosuke.tnp@gmail.com>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>

Co-authored-by: Kosuke Takeuchi <kosuke.tnp@gmail.com>
…sasakisasaki/autoware.core into feat-embed-smooth-path-as-alpha-quality

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
…sasakisasaki/autoware.core into feat-embed-smooth-path-as-alpha-quality

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
  * autowarefoundation#227 (comment)

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
…sasakisasaki/autoware.core into feat-embed-smooth-path-as-alpha-quality

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
path_up_to_just_before_pre_goal.points.push_back(prepare_pre_goal(goal, lanes));

// Replace the goal point with the refined goal
path_up_to_just_before_pre_goal.points.back().point.pose = goal;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this is a bug. Let me fix soon.

Signed-off-by: Junya Sasaki <junya.sasaki@tier4.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:planning Route planning, decision-making, and navigation. (auto-assigned) run:build-and-test-differential Mark to enable build-and-test-differential workflow. (used-by-ci) type:new-feature New functionalities or additions, feature requests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants